<!doctype html>
<html>
<?php echo $this->fetch('head.html'); ?>

<body>


<div class="fullscreen">
  <div class="scroll_contentx">
    <div class="topfixed">
      <div class="t_left"><a   href="/index.php"><i class="back"></i></a></div>
      <div class="t_main">校区选择</div>
      <a href="/index.php" class="link"><?php echo $this->_var['site']['sitename']; ?></a>
    </div>
    <div class="paddingheight"></div>
    <div class="chooseSchool_search">
      <input type="text" placeholder="请输入学校名称" id="keyword" class="inp">
      <input type="button" id="search-btn" class="btn">
    </div>
    <div class="chooseSchool_position"> </div>
    <div class="chooseSchool_search_position"><i class="ico"></i>离你最近的大学：<span id="nearSite">定位中</span></div>
    <div class="choose_city_div_box">
      <div class="choose_city_div">
         <?php $_from = $this->_var['citys']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
        <div class="city <?php if ($this->_var['k'] == 0): ?>active<?php endif; ?>" to="city<?php echo $this->_var['c']['id']; ?>"><?php echo $this->_var['c']['title']; ?></div>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
      </div>
    </div>
    <div class="choose_zone_list_box">
    <div class="choose_zone_list">
        <?php $_from = $this->_var['citys']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
        <div class="citys <?php if ($this->_var['k'] != 0): ?>none<?php endif; ?>" id="city<?php echo $this->_var['c']['id']; ?>">
        <?php if ($this->_var['c']['child']): ?>
        <?php $_from = $this->_var['c']['child']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?>
          
          <div class="zone_tt"><?php echo $this->_var['cc']['title']; ?></div>
          
          <div class="site_list"> 
          <?php if ($this->_var['cc']['sites']): ?>
          <?php $_from = $this->_var['cc']['sites']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 's');if (count($_from)):
    foreach ($_from AS $this->_var['s']):
?>
          <a href="/index.php?siteid=<?php echo $this->_var['s']['siteid']; ?>">
            <div class="site"><?php echo $this->_var['s']['sitename']; ?></div>
            </a>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            <?php endif; ?>
            </div>
          
          <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>  
          <?php endif; ?>
          </div>
          <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>  
           
     
    </div>
    
    </div>
  </div>
</div>




  
 
 <style>
    	.search_result{position:absolute;  top:90px; right:0px; left:0px; background-color:#fff; padding:10px; display:none}
		.search_result .item{line-height:30px; height:30px;}
    </style>
<div class="search_result" id="search_result">
    	<div class="item"></div>
    </div>
  
 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<?php echo BDMAPKEY; ?>"></script> 
 <script>
 $(function(){
	 $(document).on("click",".city",function(){
		$(".city").removeClass("active");
		$(this).addClass("active");
		$(".citys").addClass("none");
		$("#"+$(this).attr("to")).removeClass("none"); 
	 });
	 var word="";
	 $("#search-btn").on("click",function(){
		  
			  
			 $.get("/index.php?m=sites&a=search&ajax=1",{keyword:$("#keyword").val()},function(data){
				 if(data.error){
					 $("#search_result").html("");
				 }else{
					 var html="";
					 for(var i=0;i<data.data.length;i++){
						html=html+'<div class="item" siteid="'+data.data[i].siteid+'">'+data.data[i].sitename+'</div>'; 
					 }
					 $("#search_result").html(html).show();
				 }
			 },"json");
		  
	 });
	 $(document).on("click","#search_result .item",function(data){
		 window.location="/index.php?siteid="+$(this).attr("siteid");
	 })
	 $(".fullscreen").click(function(){
		  $("#search_result").hide();
	 });
	var lat,lng;
	var geolocation = new BMap.Geolocation();
	 
		geolocation.getCurrentPosition(function(r){
		if(this.getStatus() == BMAP_STATUS_SUCCESS){
			lat=r.point.lat;
			lng=r.point.lng;
			$.get("/index.php?m=sites&a=near&ajax=1",{lat:lat,lng:lng},function(data){
				if(data.error==0){
					$("#nearSite").html('<a href="/index.php?siteid='+data.data.siteid+'">'+data.data.sitename+'</a>');
				}
			},"json")
		}
		else {
			skyToast('获取位置失败'+this.getStatus());
		}        
	},{enableHighAccuracy: true})
		
	 
 })
 
 </script>
</body>
</html>
